﻿/*===================================================
* CLR版本  : 4.0.30319.42000 
* 类名称   : ComponentFactory
* 文 件 名 : ComponentFactory 
* 类描述   :
* 创建人   : oream
* 创建时间 : 2018/3/7 21:50:06
* 修改人   : 
* 修改时间 :
* 版本： @version 1.0
=====================================================*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotfix
{
  public class ComponentFactory
  {
    public static T Create<T>(Entity parent) where T : Component
    {
      T t = SHotfix.ObjectPool.FetchObject<T>();
      t.Parent = parent;
      SHotfix.ObjectEvent.Awake(t);
      return t;
    }

    public static T1 Create<T1, T2>(Entity parent, T2 t2) where T1 : Component
    {
      T1 tmp = SHotfix.ObjectPool.FetchObject<T1>();
      tmp.Parent = parent;
      SHotfix.ObjectEvent.Awake(tmp, t2);
      return tmp;
    }

    public static T1 Create<T1, T2, T3>(Entity parent, T2 t2, T3 t3) where T1 : Component
    {
      T1 tmp = SHotfix.ObjectPool.FetchObject<T1>();
      tmp.Parent = parent;
      SHotfix.ObjectEvent.Awake(parent, t2, t3);
      return tmp;
    }

    public static T1 Create<T1, T2, T3, T4>(Entity parent, T2 t2, T3 t3, T4 t4) where T1 : Component
    {
      T1 tmp = SHotfix.ObjectPool.FetchObject<T1>();
      tmp.Parent = parent;
      SHotfix.ObjectEvent.Awake(parent, t2, t3, t4);
      return tmp;
    }

  }
}
